package com.example.comment.utils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author QingZeyu
 * @date 2024/5/6 15:16
 */
public class PageResult<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    private long total;

    private List<T> records;

    public PageResult(long total, List<T> records) {
        this.total = total;
        this.records = records;
    }

    public PageResult() {
    }

    public static <T> PageResult<T> build(long total, List<T> list) {
        return new PageResult<>(total, list);
    }

    public static <T> PageResult<T> empty() {
        return build(0L, new ArrayList<>());
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public List<T> getRecords() {
        return records;
    }

    public void setRecords(List<T> records) {
        this.records = records;
    }

    @Override
    public String toString() {
        return "PageRecord{" +
                "total=" + total +
                ", records=" + records +
                '}';
    }
}
